﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width:600px; margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>编辑文章&nbsp;-&nbsp;基本信息</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/articles/${article.id}" data-validate="true">
    
      <input type="hidden" name="_method" value="PATCH">
      <input type="hidden" name="articleId" value="${article.id}">

      <div class="modal-body">
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">文章名称</label>
          <div class="pull-left col-xs-8">
            <input type="text" name="name" value="${article.name}" class="form-control" data-validate="required">
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">文章简介</label>
          <div class="pull-left col-xs-8">
            <textarea name="summary" data-validate="required" rows="5" style="width: 100%;">${article.summary}</textarea>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">文章类别</label>
         <div class="pull-left col-xs-8">
            <select name="moduleIds" multiple class="form-control select2" data-validate="required">
              <c:forEach var="module" items="${persist.modules}">
              	<c:if test="${not module.value.disabled}">
                	<option value="${module.key}" ${article.containsModule(module.value.id) ? 'selected' : ''}>${module.value.name}</option>
                </c:if>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">文章链接</label>
          <div class="pull-left col-xs-8">
            <textarea name="link" data-validate="required|www" rows="5" style="width: 100%;">${article.link}</textarea>
          </div>
        </div>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>

<script src="${ctx.resource}/js/component/bootstrap.validate.js"></script>
<script src="${ctx.resource}/js/component/bootstrap.validate.en.js"></script>
<script src="${ctx.resource}/js/bootstrap.validate.trigger.js"></script>
<script>
$(document).ready(function(){
  $('select[name="moduleIds"]').select2({
     placeholder: '选择所属模块',
     minimumResultsForSearch: -1,
     allowClear: true
  });
  
});
</script>